package com.xfatm.killer.task;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.transition.Fade;

import com.xfatm.killer.MainActivity;
import com.xfatm.killer.StartActivity;
import com.xfatm.killer.entity.AppInfoController;
import com.xfatm.killer.util.Activitys;

/**
 * Created by wenjie on 2018/3/30.
 */

public class StartLoadTask extends AsyncTask{

    private Activity activity;
    public StartLoadTask(Activity activity) {
        this.activity=activity;
    }

    @Override
    protected Object doInBackground(Object[] objects) {
        long time=System.currentTimeMillis();
        AppInfoController.getInstance();
        /*time=System.currentTimeMillis()-time;
        if(time<1000){
            try {
                Thread.sleep(1000L-time);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }*/
        publishProgress();
        return null;
    }

    @Override
    protected void onProgressUpdate(Object[] values) {
        Intent intent=new Intent(activity, MainActivity.class);
        activity.getWindow().setEnterTransition(new Fade().setDuration(400));
        activity.getWindow().setExitTransition(new Fade().setDuration(400));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        Activitys.finish(activity);
    }
}
